//package com.travel.travelServer.service1.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.github.pagehelper.PageHelper;
//import com.github.pagehelper.PageInfo;
//import com.travel.travelServer.entity1.*;
//import com.travel.travelServer.entity1.Landscapes;
//import com.travel.travelServer.entity1.vo.CommentVo;
//import com.travel.travelServer.entity1.vo.LandscapesVo;
//import com.travel.travelServer.mapper1.*;
//import com.travel.travelServer.mapper1.LandscapesMapper;
//import com.travel.travelServer.service1.LandscapesService;
//import com.travel.travelServer.utils.BaseService;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.*;
//
//
///**
// * <p>
// *  Landscapes表 业务接口实现
// * </p>
// *
// * @author <>
// *
// */
//@Service
//public class LandscapesServiceImpl extends BaseService<LandscapesMapper, Landscapes> implements LandscapesService {
//
//    @Autowired
//    LandscapesMapper landscapesMapper;
//
//    @Autowired
//    CollectMapper collectMapper;
//
//    @Autowired
//    CommentMapper commentMapper;
//
//    @Autowired
//    UserMapper userMapper;
//
//    /**
//     * 新增Landscapes
//     *
//     * @param landscapesVo
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int insertLandscapes(LandscapesVo landscapesVo) {
//        Date date = new Date();
//        landscapesVo.setCreateTime(date);
//        landscapesVo.setUpdateTime(date);
//        landscapesVo.setCreateBy("admin");
//        landscapesVo.setUpdateBy("admin");
//        landscapesMapper.insert(landscapesVo);
//        return 1;
//    }
//
//    /**
//     * 单个删除Landscapes信息
//     *
//     * @param id-主键
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int deleteById(Long id) {
//        return landscapesMapper.deleteById(id);
//    }
//
//    /**
//     * 批量删除Landscapes信息
//     *
//     * @param ids-主键[]
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int deleteByIds(Long[] ids) {
//        return landscapesMapper.deleteBatchIds(Arrays.asList(ids));
//    }
//
//    /**
//     * 修改Landscapes
//     *
//     * @param landscapesVo
//     * @return 结果
//     */
//    @Transactional(rollbackFor = Exception.class)
//    @Override
//    public int updateLandscapes(LandscapesVo landscapesVo) {
//        landscapesMapper.updateById(landscapesVo);
////        LambdaQueryWrapper<LandscapesMenu> wrapper = new LambdaQueryWrapper<>();
////        wrapper.eq(LandscapesMenu::getLandscapesId, landscapesVo.getId());
////        landscapesMenuMapper.delete(wrapper);
////        List<Long> menuIds = landscapesVo.getMenuIds();
////        if (menuIds.size() > 0){
////            for (Long menuId : menuIds) {
////                LandscapesMenu landscapesMenu = new LandscapesMenu();
////                landscapesMenu.setLandscapesId(landscapesVo.getId());
////                landscapesMenu.setMenuId(menuId);
////                landscapesMenuMapper.insert(landscapesMenu);
////            }
////        }
//        return 1;
//    }
//
//    /**
//     * 查询Landscapes
//     *
//     * @param id-主键
//     * @return landscapes
//     */
//    @Override
//    public Landscapes selectById(Long id) {
//        return landscapesMapper.selectById(id);
//    }
//
//    /**
//     * 查询Landscapes列表
//     *
//     * @param landscapesVo
//     * @return Landscapes集合
//     */
//    @Override
//    public List<Landscapes> selectLandscapesList(LandscapesVo landscapesVo) {
//        LambdaQueryWrapper<Landscapes> queryWrapper = new LambdaQueryWrapper<>();
//        //queryWrapper.eq(Landscapes::getId, landscapesVo.getId).select(Landscapes::getId);
//        List<Landscapes> landscapes = landscapesMapper.selectList(queryWrapper);
//        for (Landscapes landscape : landscapes) {
//            LambdaQueryWrapper<Collect> wrapper = new LambdaQueryWrapper<>();
//            wrapper.eq(Collect::getUserId, getCurrentUser().getId());
//            wrapper.eq(Collect::getLandscapesId, landscape.getId());
//            Collect collect = collectMapper.selectOne(wrapper);
//            if (Objects.nonNull(collect)){
//                landscape.setIsCollected(true);
//            }else {
//                landscape.setIsCollected(false);
//            }
//            LambdaQueryWrapper<Comment> commentWrapper = new LambdaQueryWrapper<>();
//            commentWrapper.eq(Comment::getLandscapesId, landscape.getId());
//            List<Comment> comments = commentMapper.selectList(commentWrapper);
//            List<CommentVo> commentVos = new ArrayList<>();
//            for (Comment comment : comments) {
//                CommentVo commentVo = new CommentVo();
//                BeanUtils.copyProperties(comment, commentVo);
//                User user = userMapper.selectById(comment.getUserId());
//                commentVo.setUser(user);
//                commentVos.add(commentVo);
//            }
//            landscape.setCommentVos(commentVos);
//        }
//        return landscapes;
//    }
//
//    @Override
//    public PageInfo<Landscapes> getInfoPage(LandscapesVo landscapesVo) {
//        // 使用 PageHelper 分页
//        PageHelper.startPage(landscapesVo.getPageNum(), landscapesVo.getPageSize());
//        LambdaQueryWrapper<Landscapes> wrapper = new LambdaQueryWrapper<>();
//        wrapper.like(Landscapes::getName, landscapesVo.getName());
//        List<Landscapes> landscapess = landscapesMapper.selectList(wrapper);
//        return new PageInfo<>(landscapess);
//    }
//
//}
